<?php

	/**
	 * File : login.php
	 * Description : Authentification de l'utilisateur
	 * Date : 07.08.2012 15:26:06
	 * 
	 * This file is part of Phenix.  Phenix is free software: you can
	 * redistribute it and/or modify it under the terms of the GNU General Public
	 * License as published by the Free Software Foundation, version 2.
	 *
	 * This program is distributed in the hope that it will be useful, but WITHOUT
	 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
	 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
	 * details.
	 *
	 * You should have received a copy of the GNU General Public License along with
	 * this program; if not, write to the Free Software Foundation, Inc., 51
	 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
	 *
	 * Nils Schaetti <n.schaetti@gmail.com>
	**/

	// Librairie
	require_once('core/libphenix.php');
	require_once('KTK/ktk.php');

	// Buffer
	ob_start();

	// Démarre une session
	session_start();

	// Connexion à la base de données
	ktkConnectDB();

	// En tête HTML
	lp_htmlHeader('Authentification');

	// Variables passées
	$username = $_POST['username'];
	$password = $_POST['password'];

	// Tentative de connexion
	if(!ktkLogin($username,$password))
		header('Location: index.php?error=true');
	else
		header('Location: main/home.php');

	// Fin HTML
	lp_htmlFooter();

	// Fermeture de la DB
	ktkCloseDB();

	// Fin buffer
	ob_end_flush();

?>	
